package com.foxconn.AppDownload.util;

/**
 * @author zengdong
 * @version 1.0
 * @date 2024/1/3 14:59
 */
import java.io.FileInputStream;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Properties;
import java.util.regex.Pattern;

public class HttpClient {
    public static void main(String[] args) {

        // 解析终端的 IP 地址
        String clientIp = "171.191.1.2";

        Properties properties = new Properties();
        try (FileInputStream fis = new FileInputStream("config.properties")) {
            properties.load(fis);
            String[] ips = properties.getProperty("server.ip").split(",\\s*");
            boolean isMatched = false;
            for (String ip : ips) {
                if (Pattern.matches(ip.replace(".", "\\.").replace("*", "[0-9]*"), clientIp)) {
                    isMatched = true;
                    break;
                }
            }
            System.out.println("Is client IP matched: " + isMatched);
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
